const router = require('koa-router')()

const { exec } = require('../db/index')

router.get('/getlist', async (ctx, next) => {
  console.log(ctx.query)
  const {pageIndex,pageSize}=ctx.query
  let sql = `SELECT * FROM juejin LIMIT ${pageIndex},${pageSize}`;
  let sqlz = `SELECT * FROM juejin`
  let data = await exec(sql)
  let total = await exec(sqlz)
  console.log(total.length)
  // console.log(data)
  ctx.body = {
    data,
    total:total.length
  }
})

module.exports = router
